function new_data=f_montage(eeg_data)
for jc_channel = 1:31
    std_each(jc_channel) = std(eeg_data(jc_channel,:));
end
Mstd = mean(std_each);
% figure;plot(std_each)
MM = 1:31;
for jc_channel = 1:31
    if std_each(jc_channel) >4.*Mstd;
        MM(jc_channel) = [];
    end
end
% MM
montage = mean(eeg_data(MM,:)); % common montage should not include the bad channels;

for jc_channel = 1:31
    new_data(jc_channel,:)=eeg_data(jc_channel,:)- montage;
    
%     if std_each(jc_channel) >4.*Mstd
%         new_data(jc_channel,:)=0.*new_data(jc_channel,:);
%     end
%     temp = new_data(jc_channel,:);
%     temp(temp>4.*mean(std_each)) =4.*Mstd;
%     temp(temp<-4.*mean(std_each)) = -4.*Mstd;
%     new_data(jc_channel,:) = temp;
end